package com.sync.data.mce.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.sync.data.base.BaseEntity;
import com.sync.data.base.CoreField;
import com.sync.data.common.annotation.FieldProps;
import com.sync.data.common.annotation.FieldType;
import com.sync.data.common.annotation.RenderType;
import com.sync.data.common.obj.annoation.ObjectPrefix;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;


@Getter
@Setter
@Entity
@ObjectPrefix("bpos")
@Table(name = "base_position")
public class MceBasePosition extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @FieldProps(type = FieldType.STRING, label = "岗位编号")
    private String positionCode;

    @FieldProps(type = FieldType.STRING, label = "岗位名称")
    private String positionName;

    @FieldProps(type = FieldType.STRING, label = "父岗位id")
    private String pid;

    @FieldProps(type = FieldType.STRING, label = "BU")
    private String departmentName;

    @FieldProps(type = FieldType.STRING, label = "部门编号")
    private String departmentCode;

    @FieldProps(type = FieldType.STRING, label = "岗位级别")
    private Integer positionLevel;

    @FieldProps(type = FieldType.STRING, label = "团队编号")
    private String teamCode;

    @FieldProps(type = FieldType.STRING, label = "PT")
    private String teamName;

    @FieldProps(type = FieldType.STRING, label = "是否生效")
    private Integer isActive;

    @FieldProps(type = FieldType.STRING, label = "是否最终层级")
    private Integer isFinalOrg;

    @FieldProps(type = FieldType.STRING, label = "标准岗位类型")
    private String standardPositionType;

    @FieldProps(type = FieldType.STRING, label = "周期编码")
    private String cycleCode;

    @FieldProps(type = FieldType.STRING, label = "版本编码")
    private String dataVersionCode;

    @FieldProps(type = FieldType.STRING, label = "作战事业部")
    private String vid;

    @FieldProps(type = FieldType.STRING, label = "外键ID")
    private String externalId;

    @FieldProps(type = FieldType.STRING, label = "customField1")
    private String customField1;
    @FieldProps(type = FieldType.STRING, label = "customField2")
    private String customField2;
    @FieldProps(type = FieldType.STRING, label = "customField3")
    private String customField3;
    @FieldProps(type = FieldType.STRING, label = "customField4")
    private String customField4;
    @FieldProps(type = FieldType.STRING, label = "customField5")
    private String customField5;

    @FieldProps(type = FieldType.STRING, label = "开始时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    private Date beginDate;


    @FieldProps(type = FieldType.STRING, label = "结束时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endDate;

    @FieldProps(type = FieldType.STRING, label = "英文标题名称")
    private String titleNameEn;

    @FieldProps(type = FieldType.STRING, label = "上级岗位编号")
    private String parentCode;

    @FieldProps(type = FieldType.STRING, label = "上级岗位名称")
    private String parentName;

    @FieldProps(type = FieldType.STRING, label = "删除标识")
    private String delFlag;

//    @OneToMany(fetch = FetchType.LAZY)
//    @JoinColumn(name = "positionCode", referencedColumnName = "positionCode" ,insertable = false, updatable = false)
//    private List<BasePositionEmployee> basePositionEmployees;

    @FieldProps(type =FieldType.STRING,label = "周期id")
    private String basePositionPeriodId;


    @FieldProps(type = FieldType.STRING, label = "虚线上级岗位名称")
    private String dottedParentPositionName;

    @FieldProps(type = FieldType.STRING, label = "虚线上级岗位编码")
    private String dottedParentPositionCode;

    @FieldProps(type = FieldType.STRING, label = "岗位职能")
    private String positionFunction;

    @FieldProps(type = FieldType.STRING, label = "成本中心")
    private String costCenter;

    @FieldProps(type = FieldType.STRING, label = "成本中心编码")
    private String costCenterCode;

    @FieldProps(type = FieldType.STRING, label = "子公司")
    private String subsidiary;

    @FieldProps(type = FieldType.DICT, label = "辖区", renderType = RenderType.Select)
    private String jurisdiction;

    @Transient
    @FieldProps(type = FieldType.STRING, label = "辖区")
    private CoreField jurisdictionDict;

    //岗位层级
    @FieldProps(type = FieldType.DICT, label = "岗位层级", renderType = RenderType.Select)
    private String spmPositionLevel;

    @Transient
    @FieldProps(type = FieldType.STRING, label = "岗位层级")
    private CoreField spmPositionLevelDict;

    @FieldProps(type = FieldType.STRING, label = "岗位类型")
    private String spmRecordType;

    @FieldProps(type = FieldType.DICT, label = "职位", renderType = RenderType.Select)
    private String levelLabel;

    @Transient
    @FieldProps(type = FieldType.STRING, label = "职位")
    private CoreField levelLabelDict;


    @FieldProps(type = FieldType.DICT, label = "岗位类型", renderType = RenderType.Select)
    private String positionType;

    @Transient
    @FieldProps(type = FieldType.STRING, label = "岗位类型")
    private CoreField positionTypeDict;


//    @OneToOne(fetch = FetchType.EAGER)
//    @NotFound(action = NotFoundAction.IGNORE)
//    @JsonIgnoreProperties("basePositionPeriod")
//    @JoinColumn(name = "basePositionCurrentId", referencedColumnName = "id" ,insertable = false, updatable = false)
//    private BasePositionCurrent basePositionCurrent;
//
//    private String basePositionCurrentId;

    /** 原始数据id */
    private String legacyId;

    /** 迭代id */
    private String iterationId;

    private String sysOrgCode;


    public MceBasePosition(String id, String positionCode, String pid) {
        this.id = id;
        this.pid = pid;
        this.positionCode = positionCode;
    }

    public MceBasePosition() {

    }
}
